{include file="public/layout" /}
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit; min-width:400px;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page" style="min-width: 400px;">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>邮件模板</h3>
                <h5></h5>
            </div>
            <ul class="tab-base nc-row">
                <li><a href="{:url("System/smtp_tpl")}" class="tab {eq name="$Request.action" value="smtp_tpl"}current{/eq}"><span>模板列表</span></a></li>

                {eq name="'System@smtp_edit'|is_check_access" value="1"}
                <li><a href="javascript:void(0);" class="tab {if condition="in_array($Request.action, array('smtp_tpl_edit'))"}current{/if}"><span>编辑模板</span></a></li>
                {/eq}
            </ul>
        </div>
    </div>
    <form class="form-horizontal" id="post_form" action="{:url('System/smtp_tpl_edit')}" method="post">
        <input type="hidden" name="tpl_id" value="{$row.tpl_id}">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label for="tpl_title"><em>*</em>邮件标题</label>
                </dt>
                <dd class="opt">
                    <input id="tpl_title" name="tpl_title" value="{$row.tpl_title}" class="input-txt" type="text"/>
                    <p class="notic"></p>
                </dd>
            </dl>
            <!-- <dl class="row">
                <dt class="tit">
                    <label for="tpl_content">发送邮件内容</label>
                </dt>
                <dd class="opt">
                    <textarea class="span12 ckeditor" id="post_content" name="tpl_content" title="">{$row.tpl_content}</textarea>   
                    <p class="notic"> 发送模板邮件内容，请按照格式进行修改 </p>
                </dd>
            </dl> -->
            <div class="bot"><a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
        </div>
    </form>
</div>
<script type="text/javascript">

    // 判断输入框是否为空
    function checkForm(){
        if($.trim($('input[name=tpl_title]').val()) == ''){
            showErrorMsg('邮件标题不能为空！');
            $('input[name=tpl_title]').focus();
            return false;
        }

        layer_loading('正在处理');
        $.ajax({
            url: "{:url('System/smtp_tpl_edit', ['_ajax'=>1])}",
            type: 'POST',
            dataType: 'JSON',
            data: $('#post_form').serialize(),
            success: function(res){
                layer.closeAll();
                if (res.code == 1) {
                    layer.msg(res.msg, {shade: 0.1, time: 1000}, function(){
                        window.location.href = res.url;
                    });
                } else {
                    layer.alert(res.msg, {icon:5, title:false});
                }
            },
            error: function(e){
                layer.closeAll();
                layer.alert(e.responseText, {icon:5, title:false});
            }
        });

        return false;
    }
</script>
{include file="public/footer" /}